<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 6.3.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon.jpg">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon.jpg">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"matian.connorma.cn","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="minio提供对象存储，支持单节点部署及集群部署；集群部署模式下最少4节点，集群需要至少N&#x2F;2节点在线才可读，至少N&#x2F;2+1节点在线才可写——准确的说，至少需要4块“盘”，两个节点每个节点两块“盘”也是可行的 以下记录centos 7下的minio单机及集群部署，最初只记录了minio单节点部署，现在进行了完善，替换为minio新版本，通过配置文件的方式自动识别按单机模式或者集">
<meta property="og:type" content="article">
<meta property="og:title" content="minio单机及集群部署">
<meta property="og:url" content="http://matian.connorma.cn/db92b212.html">
<meta property="og:site_name" content="马天">
<meta property="og:description" content="minio提供对象存储，支持单节点部署及集群部署；集群部署模式下最少4节点，集群需要至少N&#x2F;2节点在线才可读，至少N&#x2F;2+1节点在线才可写——准确的说，至少需要4块“盘”，两个节点每个节点两块“盘”也是可行的 以下记录centos 7下的minio单机及集群部署，最初只记录了minio单节点部署，现在进行了完善，替换为minio新版本，通过配置文件的方式自动识别按单机模式或者集">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2020-02-22T07:21:17.000Z">
<meta property="article:modified_time" content="2024-05-26T11:48:06.731Z">
<meta property="article:author" content="马天">
<meta property="article:tag" content="minio">
<meta property="article:tag" content="linux">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://matian.connorma.cn/db92b212.html">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>minio单机及集群部署 | 马天</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">马天</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://matian.connorma.cn/db92b212.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="马天">
      <meta itemprop="description" content="程序猿">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="马天">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          minio单机及集群部署
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2020-02-22 15:21:17" itemprop="dateCreated datePublished" datetime="2020-02-22T15:21:17+08:00">2020-02-22</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/minio/" itemprop="url" rel="index"><span itemprop="name">minio</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>minio提供对象存储，支持单节点部署及集群部署；集群部署模式下最少4节点，集群需要至少N&#x2F;2节点在线才可读，至少N&#x2F;2+1节点在线才可写——准确的说，至少需要4块“盘”，两个节点每个节点两块“盘”也是可行的</p>
<p>以下记录centos 7下的minio单机及集群部署，最初只记录了minio单节点部署，现在进行了完善，替换为minio新版本，通过配置文件的方式自动识别按单机模式或者集群模式启动</p>
<span id="more"></span>

<h2 id="部署准备"><a href="#部署准备" class="headerlink" title="部署准备"></a>部署准备</h2><h3 id="服务器配置"><a href="#服务器配置" class="headerlink" title="服务器配置"></a>服务器配置</h3><ul>
<li>部署minio的所有主机配置时间同步，保持时间一致，否则minio集群无法启动</li>
<li>视情况进行磁盘挂载，文件系统参数、ulimit参数调整等</li>
</ul>
<h3 id="minio安装"><a href="#minio安装" class="headerlink" title="minio安装"></a>minio安装</h3><p>准备minio rpm包，minio版本更新很快，选用<a target="_blank" rel="noopener" href="https://dl.min.io/server/minio/release/linux-amd64/archive/minio-20210817205308.0.0.x86_64.rpm">minio-20210817205308.0.0.x86_64.rpm</a>，在所有minio所在主机安装：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">安装minio包</span></span><br><span class="line">rpm -ivh --nodeps minio-20210817205308.0.0.x86_64.rpm</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">添加minio软链</span></span><br><span class="line">ln -s /usr/local/bin/minio /usr/bin/minio</span><br><span class="line">minio -v</span><br></pre></td></tr></table></figure>

<p>创建minio用户及用户目录</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">useradd minio</span><br><span class="line">su - minio</span><br><span class="line">cd ~</span><br><span class="line">mkdir minio-server</span><br><span class="line">cd minio-server</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">minio启停脚本路径</span></span><br><span class="line">mkdir bin</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">minio配置文件路径</span></span><br><span class="line">mkdir conf</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">minio日志文件路径</span></span><br><span class="line">mkdir logs</span><br></pre></td></tr></table></figure>

<p>创建minio数据路径，这里将数据存储到了数据盘挂载点&#x2F;data下</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">cd /data</span><br><span class="line">mkdir minio_data</span><br><span class="line">chown minio:minio -R minio_data</span><br><span class="line">chmod -R 750 minio_data</span><br></pre></td></tr></table></figure>

<h3 id="nginx部署"><a href="#nginx部署" class="headerlink" title="nginx部署"></a>nginx部署</h3><p>部署nginx代理minio，一部分是上传文件到minio的代理，一部分是minio文件外链的代理</p>
<p>nginx部署可参考<a target="_blank" rel="noopener" href="https://gitee.com/connormma/quick_launch_tools/blob/master/nginx/linux_amd64/">此脚本</a></p>
<h2 id="minio集群模式部署"><a href="#minio集群模式部署" class="headerlink" title="minio集群模式部署"></a>minio集群模式部署</h2><p>minio单节点standlone模式部署过程与集群模式下单节点部署只最终的启动命令不同，这里不进行演示。本文将给出一个启动脚本，根据conf&#x2F;路径下配置文件内容，自动判断单节点启动OR集群模式启动</p>
<p>服务器IP为：</p>
<ul>
<li>192.168.1.1</li>
<li>192.168.1.2</li>
<li>192.168.1.3</li>
<li>192.168.1.4</li>
</ul>
<p>conf&#x2F;下添加minio.conf文件，完整的配置文件示例为：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"># minio控制台root用户名，所有minio节点使用相同的用户名和密码</span><br><span class="line"># 非必填，默认为minio</span><br><span class="line">MINIO_ROOT_USER=minio</span><br><span class="line"># minio控制台root用户密码，所有minio节点使用相同的用户名和密码</span><br><span class="line"># 非必填，默认为Minio!2023</span><br><span class="line">MINIO_ROOT_PASSWORD=Minio!2023</span><br><span class="line"></span><br><span class="line"># 是否使用集群模式部署，1-集群模式 0-单机模式</span><br><span class="line">MINIO_CLUSTER_MODE=1</span><br><span class="line"></span><br><span class="line"># 单机模式相关配置，集群模式将忽略</span><br><span class="line"># 单机模式下，minio存储服务端口</span><br><span class="line"># 非必填，默认为9210</span><br><span class="line">MINIO_SERVER_PORT=9210</span><br><span class="line"># 单机模式下，minio控制台服务端口</span><br><span class="line"># 非必填，默认为9211</span><br><span class="line">MINIO_CONSOLE_PORT=9211</span><br><span class="line"># 单机模式下，minios数据目录</span><br><span class="line"># 非必填，默认为 &#123;MINIO_HOME&#125;/data</span><br><span class="line">MINIO_DATA_PATH=/home/minio/minio-server/data</span><br><span class="line"></span><br><span class="line"># 集群相关配置，单机模式下将忽略</span><br><span class="line"># 集群节点列表</span><br><span class="line"># 节点地址，格式为： MINIO_CLUSTER_NODE[节点ID]=节点ip:节点server端口:节点console端口:节点data路径</span><br><span class="line"># 约定节点ID为不重复的、递增的、连续的正整数，1,2,3,4....</span><br><span class="line">MINIO_CLUSTER_NODE[1]=192.168.1.1:9210:9211:/data/minio_data</span><br><span class="line">MINIO_CLUSTER_NODE[2]=192.168.1.2:9210:9211:/data/minio_data</span><br><span class="line">MINIO_CLUSTER_NODE[3]=192.168.1.3:9210:9211:/data/minio_data</span><br><span class="line">MINIO_CLUSTER_NODE[4]=192.168.1.4:9210:9211:/data/minio_data</span><br><span class="line"># 当前节点的ID</span><br><span class="line">MINIO_CLUSTER_NODE_ID=1</span><br></pre></td></tr></table></figure>

<p>添加启动脚本bin&#x2F;start_up.sh，使用minio用户执行此脚本即将按照文件配置启动minio节点</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">minio部署路径，默认为minio用户目录下minio-server下</span></span><br><span class="line">MINIO_HOME=&#x27;/home/minio/minio-server&#x27;</span><br><span class="line"></span><br><span class="line">if [ ! -d $&#123;MINIO_HOME&#125; ]</span><br><span class="line">then</span><br><span class="line">    echo &quot;ERROR! path $&#123;MINIO_HOME&#125; not found!&quot;</span><br><span class="line">    exit 1</span><br><span class="line">fi</span><br><span class="line"></span><br><span class="line">echo &quot;minio home path is: $&#123;MINIO_HOME&#125;&quot;</span><br><span class="line"></span><br><span class="line">MINIO_CONFIG_DIR=$&#123;MINIO_HOME&#125;&#x27;/conf&#x27;</span><br><span class="line">if [ ! -d $&#123;MINIO_CONFIG_DIR&#125; ]</span><br><span class="line">then</span><br><span class="line">    mkdir -p $&#123;MINIO_CONFIG_DIR&#125;</span><br><span class="line">fi</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">MINIO_LOG_PATH=$&#123;MINIO_HOME&#125;&#x27;/logs&#x27;</span><br><span class="line">if [ ! -d $&#123;MINIO_LOG_PATH&#125; ]</span><br><span class="line">then</span><br><span class="line">    mkdir -p $&#123;MINIO_LOG_PATH&#125;</span><br><span class="line">fi</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">读取minio配置文件</span></span><br><span class="line">if [ -f $&#123;MINIO_CONFIG_DIR&#125;&#x27;/minio.conf&#x27; ]</span><br><span class="line">then</span><br><span class="line">    . $&#123;MINIO_CONFIG_DIR&#125;&#x27;/minio.conf&#x27;</span><br><span class="line">fi</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">读取minio控制台root用户账号</span></span><br><span class="line">if [ &#x27;X&#x27;$&#123;MINIO_ROOT_USER&#125; == &#x27;X&#x27; ]</span><br><span class="line">then</span><br><span class="line">    MINIO_ROOT_USER=minio</span><br><span class="line">fi</span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">读取minio控制台root用户密码</span></span><br><span class="line">if [ &#x27;X&#x27;$&#123;MINIO_ROOT_PASSWORD&#125; == &#x27;X&#x27; ]</span><br><span class="line">then</span><br><span class="line">    MINIO_ROOT_PASSWORD=Minio!2023</span><br><span class="line">fi</span><br><span class="line">export MINIO_ROOT_USER=$&#123;MINIO_ROOT_USER&#125;</span><br><span class="line">export MINIO_ROOT_PASSWORD=$&#123;MINIO_ROOT_PASSWORD&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">if [ &#x27;X&#x27;$&#123;MINIO_CLUSTER_MODE&#125; == &#x27;X&#x27; ]</span><br><span class="line">then</span><br><span class="line">    echo &quot;ERROR! MINIO_CLUSTER_MODE should be 0(standlone mode) or 1(cluster mode) !&quot;</span><br><span class="line">    exit 1</span><br><span class="line">fi</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">if [ $&#123;MINIO_CLUSTER_MODE&#125; -eq 0 ]</span><br><span class="line">then</span><br><span class="line">    if [ &#x27;X&#x27;$&#123;MINIO_SERVER_PORT&#125; == &#x27;X&#x27; ]</span><br><span class="line">    then</span><br><span class="line">        MINIO_SERVER_PORT=9210</span><br><span class="line">    fi</span><br><span class="line"></span><br><span class="line">    if [ &#x27;X&#x27;$&#123;MINIO_CONSOLE_PORT&#125; == &#x27;X&#x27; ]</span><br><span class="line">    then</span><br><span class="line">        MINIO_CONSOLE_PORT=9211</span><br><span class="line">    fi</span><br><span class="line"></span><br><span class="line">    # 读取minio data路径</span><br><span class="line">    if [ &#x27;X&#x27;$&#123;MINIO_DATA_PATH&#125; == &#x27;X&#x27; ]</span><br><span class="line">    then</span><br><span class="line">        MINIO_DATA_PATH=$&#123;MINIO_HOME&#125;&#x27;/data&#x27;</span><br><span class="line">    fi</span><br><span class="line">    if [ ! -d $&#123;MINIO_DATA_PATH&#125; ]</span><br><span class="line">    then</span><br><span class="line">        mkdir -p $&#123;MINIO_DATA_PATH&#125;</span><br><span class="line">    fi</span><br><span class="line">    chown minio:minio -R $&#123;MINIO_DATA_PATH&#125;</span><br><span class="line">    chmod -R 750 $&#123;MINIO_DATA_PATH&#125;</span><br><span class="line"></span><br><span class="line">    # 启动minio-server</span><br><span class="line">    nohup minio  server --address &quot;:$&#123;MINIO_SERVER_PORT&#125;&quot; --console-address &quot;:$&#123;MINIO_CONSOLE_PORT&#125;&quot;  $&#123;MINIO_DATA_PATH&#125; &gt; $&#123;MINIO_LOG_PATH&#125;&#x27;/log&#x27; 2&gt;&amp;1 &amp;</span><br><span class="line">    </span><br><span class="line">    echo &quot;minio started on port: $&#123;MINIO_SERVER_PORT&#125;, console port: $&#123;MINIO_CONSOLE_PORT&#125;&quot;</span><br><span class="line">    exit 0</span><br><span class="line">fi</span><br><span class="line"></span><br><span class="line">if [ $&#123;MINIO_CLUSTER_MODE&#125; -ne 0 ]</span><br><span class="line">then</span><br><span class="line">    # 读取当前节点ID</span><br><span class="line">    if [ &#x27;X&#x27;$&#123;MINIO_CLUSTER_NODE_ID&#125; == &#x27;X&#x27; ]</span><br><span class="line">    then</span><br><span class="line">        echo &quot;ERROR! must set MINIO_CLUSTER_NODE_ID when use cluster mode&quot;</span><br><span class="line">        exit 1</span><br><span class="line">    fi</span><br><span class="line">    # 读取、拼接所有节点的data路径</span><br><span class="line">    MINIO_DATA_PATH=&#x27;&#x27;</span><br><span class="line">    config_file=$&#123;MINIO_CONFIG_DIR&#125;&#x27;/minio.conf&#x27;</span><br><span class="line">    nodes_cnt=`cat $config_file | grep -v &#x27;#&#x27; | grep -F &#x27;MINIO_CLUSTER_NODE[&#x27; | wc -l`</span><br><span class="line">    for i in `seq 1 $nodes_cnt`</span><br><span class="line">    do</span><br><span class="line">        node=$&#123;MINIO_CLUSTER_NODE[$i]&#125;</span><br><span class="line">        MINIO_DATA_PATH=$&#123;MINIO_DATA_PATH&#125;&#x27; &#x27;`echo $node | awk -F&#x27;:&#x27; &#x27;&#123;print &quot;http://&quot;$1$4&#125;&#x27;`</span><br><span class="line">        node_id=`echo $node | awk -F&#x27;:&#x27; &#x27;&#123;print &quot;http://&quot;$1$4&#125;&#x27;`</span><br><span class="line">    done</span><br><span class="line"></span><br><span class="line">    MINIO_SERVER_PORT=`echo $&#123;MINIO_CLUSTER_NODE[$MINIO_CLUSTER_NODE_ID]&#125; | awk -F&#x27;:&#x27; &#x27;&#123;print $2&#125;&#x27;`</span><br><span class="line">    MINIO_CONSOLE_PORT=`echo $&#123;MINIO_CLUSTER_NODE[$MINIO_CLUSTER_NODE_ID]&#125; | awk -F&#x27;:&#x27; &#x27;&#123;print $3&#125;&#x27;`</span><br><span class="line"></span><br><span class="line">    nohup minio  server --address &quot;:$&#123;MINIO_SERVER_PORT&#125;&quot; --console-address &quot;:$&#123;MINIO_CONSOLE_PORT&#125;&quot;  $&#123;MINIO_DATA_PATH&#125; &gt; $&#123;MINIO_LOG_PATH&#125;&#x27;/log&#x27; 2&gt;&amp;1 &amp;</span><br><span class="line"></span><br><span class="line">    echo &quot;minio started on port: $&#123;MINIO_SERVER_PORT&#125;, console port: $&#123;MINIO_CONSOLE_PORT&#125;&quot;</span><br><span class="line">    exit 0</span><br><span class="line">fi</span><br><span class="line"></span><br></pre></td></tr></table></figure>


<p>添加stop.sh用于停止节点：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">minio部署路径，默认为minio用户目录下minio-server下</span></span><br><span class="line">MINIO_HOME=&#x27;/home/minio/minio-server&#x27;</span><br><span class="line"></span><br><span class="line">if [ ! -d $&#123;MINIO_HOME&#125; ]</span><br><span class="line">then</span><br><span class="line">    echo &quot;ERROR! path $&#123;MINIO_HOME&#125; not found!&quot;</span><br><span class="line">    exit 1</span><br><span class="line">fi</span><br><span class="line"></span><br><span class="line">MINIO_CONFIG_DIR=$&#123;MINIO_HOME&#125;&#x27;/conf&#x27;</span><br><span class="line">if [ ! -d $&#123;MINIO_CONFIG_DIR&#125; ]</span><br><span class="line">then</span><br><span class="line">    mkdir -p $&#123;MINIO_CONFIG_DIR&#125;</span><br><span class="line">fi</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">读取minio配置文件</span></span><br><span class="line">if [ -f $&#123;MINIO_CONFIG_DIR&#125;&#x27;/minio.conf&#x27; ]</span><br><span class="line">then</span><br><span class="line">    . $&#123;MINIO_CONFIG_DIR&#125;&#x27;/minio.conf&#x27;</span><br><span class="line">    if [ $&#123;MINIO_CLUSTER_MODE&#125; -ne 0 ]</span><br><span class="line">    then</span><br><span class="line">        # 读取当前节点ID</span><br><span class="line">        if [ &#x27;X&#x27;$&#123;MINIO_CLUSTER_NODE_ID&#125; == &#x27;X&#x27; ]</span><br><span class="line">        then</span><br><span class="line">            echo &quot;ERROR! must set MINIO_CLUSTER_NODE_ID when use cluster mode&quot;</span><br><span class="line">            exit 1</span><br><span class="line">        fi</span><br><span class="line">        MINIO_SERVER_PORT=`echo $&#123;MINIO_CLUSTER_NODE[$MINIO_CLUSTER_NODE_ID]&#125; | awk -F&#x27;:&#x27; &#x27;&#123;print $2&#125;&#x27;`</span><br><span class="line">    fi</span><br><span class="line">    lsof -i :$&#123;MINIO_SERVER_PORT&#125; | grep minio | awk &#x27;&#123;print $2&#125;&#x27; | xargs kill -9</span><br><span class="line">    echo &quot;minio process with server port $&#123;MINIO_SERVER_PORT&#125; killed&quot;</span><br><span class="line">else</span><br><span class="line">    echo &quot;ERROR! config file not found!&quot;</span><br><span class="line">    exit 1</span><br><span class="line">fi</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>部署完成后执行start_up.sh即可启动节点，访问http:&#x2F;&#x2F;<ip>:<console_port>即可访问控制台</console_port></ip></p>
<h2 id="nginx转发配置"><a href="#nginx转发配置" class="headerlink" title="nginx转发配置"></a>nginx转发配置</h2><p>使用nginx代理minio：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"># nginx用作反向代理，设置request body size，避免大文件上传失败（413）</span><br><span class="line">client_body_buffer_size  1024K;</span><br><span class="line">client_header_buffer_size 1024K;</span><br><span class="line">client_max_body_size 512m;</span><br><span class="line">large_client_header_buffers 4 256k;</span><br><span class="line"></span><br><span class="line"># minio存储服务server地址</span><br><span class="line">upstream minio_server &#123;</span><br><span class="line">  server 192.168.1.1:9210;</span><br><span class="line">  server 192.168.1.2:9210;</span><br><span class="line">  server 192.168.1.3:9210;</span><br><span class="line">  server 192.168.1.4:9210;</span><br><span class="line">&#125;</span><br><span class="line"># minio控制台服务server地址</span><br><span class="line">upstream minio_console &#123;</span><br><span class="line">  server 192.168.1.1:9211;</span><br><span class="line">  server 192.168.1.2:9211;</span><br><span class="line">  server 192.168.1.3:9211;</span><br><span class="line">  server 192.168.1.4:9211;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"># minio文件静态链接代理</span><br><span class="line">server &#123;</span><br><span class="line">    listen 80;</span><br><span class="line">    server_name oss.example.connorma.cn;</span><br><span class="line"></span><br><span class="line">    # minio examplebucket桶 静态文件转发</span><br><span class="line">    location /examplebucket/ &#123;</span><br><span class="line">      proxy_next_upstream     http_500 http_502 http_503 http_504 error timeout invalid_header;</span><br><span class="line">      proxy_set_header        Host  $host;</span><br><span class="line">      proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;</span><br><span class="line">      proxy_pass              http://minio_server;</span><br><span class="line">      # 视情况设置expires</span><br><span class="line">      expires                 0;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"># minio上传文件代理</span><br><span class="line">server &#123;</span><br><span class="line">    listen 80;</span><br><span class="line">    server_name oss-upload.example.connorma.cn;</span><br><span class="line"></span><br><span class="line">    # oss 文件操作服务代理    </span><br><span class="line">    location / &#123;</span><br><span class="line">      proxy_set_header        Host  $host;</span><br><span class="line">      proxy_set_header        X-Real-IP $remote_addr;</span><br><span class="line">      proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;</span><br><span class="line">      proxy_pass              http://minio_server;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>客户端即可使用oss-upload.example.connorma.cn操作minio文件，可使用oss.example.connorma.cn访问文件外链</p>

    </div>

    
    
    

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/minio/" rel="tag"># minio</a>
              <a href="/tags/linux/" rel="tag"># linux</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/cb87a2ee.html" rel="prev" title="Spring Boot @Import的使用">
      <i class="fa fa-chevron-left"></i> Spring Boot @Import的使用
    </a></div>
      <div class="post-nav-item">
    <a href="/9b1b03df.html" rel="next" title="使用ntp或chrony部署时间同步服务">
      使用ntp或chrony部署时间同步服务 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E9%83%A8%E7%BD%B2%E5%87%86%E5%A4%87"><span class="nav-number">1.</span> <span class="nav-text">部署准备</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%9C%8D%E5%8A%A1%E5%99%A8%E9%85%8D%E7%BD%AE"><span class="nav-number">1.1.</span> <span class="nav-text">服务器配置</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#minio%E5%AE%89%E8%A3%85"><span class="nav-number">1.2.</span> <span class="nav-text">minio安装</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#nginx%E9%83%A8%E7%BD%B2"><span class="nav-number">1.3.</span> <span class="nav-text">nginx部署</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#minio%E9%9B%86%E7%BE%A4%E6%A8%A1%E5%BC%8F%E9%83%A8%E7%BD%B2"><span class="nav-number">2.</span> <span class="nav-text">minio集群模式部署</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#nginx%E8%BD%AC%E5%8F%91%E9%85%8D%E7%BD%AE"><span class="nav-number">3.</span> <span class="nav-text">nginx转发配置</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">马天</p>
  <div class="site-description" itemprop="description">程序猿</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">41</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">17</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">25</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/matian2014" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;matian2014" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:matian1103@qq.com" title="E-Mail → mailto:matian1103@qq.com" rel="noopener" target="_blank"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        
  <div class="beian"><a href="https://beian.miit.gov.cn/" rel="noopener" target="_blank">陕ICP备2023001563号 </a>
  </div>

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2025</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">马天</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  















  

  

</body>
</html>
